package com.jlastu.znb.view;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.jlastu.znb.R;
import com.jlastu.znb.utils.SpUtils;

import java.util.Set;

public class SetActivity extends AppCompatActivity {
    private ImageView mBack;
    private LinearLayout mLinearLayout1;
    private LinearLayout mLinearLayout2;
    private LinearLayout mLinearLayout3;
    private LinearLayout mLinearLayout4;
    private LinearLayout mLinearLayout5;
    private LinearLayout mLinearLayout6;
    private LinearLayout mLinearLayout7;
    private LinearLayout mLinearLayout8;
    private LinearLayout mLinearLayout9;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
        mBack = findViewById(R.id.back);
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        mLinearLayout1 = findViewById(R.id.linearlayout1);
        mLinearLayout1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, PersonalActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout2 = findViewById(R.id.linearlayout2);
        mLinearLayout2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, AddressActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout3 = findViewById(R.id.linearlayout3);
        mLinearLayout3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, PrivacyActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout4 = findViewById(R.id.linearlayout4);
        mLinearLayout4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, PasswordActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout5 = findViewById(R.id.linearlayout5);
        mLinearLayout5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDialAlertDialog();
            }
        });
        mLinearLayout6 = findViewById(R.id.linearlayout6);
        mLinearLayout6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, FeedBackActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout7 = findViewById(R.id.linearlayout7);
        mLinearLayout7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, AboutUSActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout8 = findViewById(R.id.linearlayout8);
        mLinearLayout8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, PrivacyPolicyActivity.class);
                startActivity(intent);
            }
        });
        mLinearLayout9 = findViewById(R.id.linearlayout9);
        mLinearLayout9.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SetActivity.this, UserAgreementActivity.class);
                startActivity(intent);
            }
        });

        findViewById(R.id.goods_send).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new SpUtils(SetActivity.this).putString("userName", "");
                startActivity(new Intent(SetActivity.this,LoginActivity.class));
            }
        });
    }
    private void showDialAlertDialog() {
        new AlertDialog.Builder(SetActivity.this)
                .setTitle("温馨提示")
                .setMessage("您确定拨打客服电话：10086")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialCustomerService();
                    }
                })
                .setNegativeButton("取消", null) // 点击取消时不执行任何操作
                .create()
                .show();
    }

    // 拨打客服电话的方法
    private void dialCustomerService() {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:10086")); // 设置拨号号码
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }
    }
}

